< previous page page_645 next page >

Page 645
(table continued from previous page)
PropertyDescription
TextPositionSet this property to a value that signifies where the tooltip text is displayed. It can appear above or below for a horizontal slider or on the left or right for a vertical slider.
ToolTipTextThe text to display when the users cursor hovers over the slider control.
ValueThe value the slider is currently set to.

Using the Slider Control at Runtime
In the Slider sample form, the slider is used to control an employees salary. When the user moves the slider to affect the salary, the text box is updated. Whats more, if the user types a value into the text box, the slider control is updated. First, the Form_Load() event sets a default value for the salary:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub Form_Load()
   txtSalary.Text = Format("30000", "Currency")
   Call txtSalary_LostFocus
End Sub
After the Text property of the text box is set, the LostFocus event of the text box is called:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub txtSalary_LostFocus()
   sldSalary.Value = CCur(txtSalary.Text)
End Sub
When the user moves out of the text box, the slider control is updated to the new value entered in the text box by setting the Value property of the slider from the Text property of the text box. The Validate event is used to make sure a valid numeric value is entered into the text box:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub txtSalary_Validate(Cancel As Boolean)
   If CCur(txtSalary.Text) < sldSalary.Min Then
      Beep
      Cancel = True
   End If
   If CCur(txtSalary.Text) > sldSalary.Max Then
      Beep
      Cancel = True
   End If
End Sub

 
< previous page page_645 next page >

If you like this book, buy it!